package com.xbongbong.saas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * 列表表头
 * @author haibin.zhang
 * @version v1.0
 * @date 2019/2/13 15:54
 * @since v1.0
 */
@Getter
public enum PageTitleEnum {
    // 列表表头
    CUSTOMER(XbbRefTypeEnum.CUSTOMER.getCode(),"enum.pageTitle.name.customer",""),
    CUSTOMER_FOCUS(XbbRefTypeEnum.CUSTOMER_FOCUS.getCode(),"enum.pageTitle.name.customer_focus",""),
    CUSTOMER_DEAL(XbbRefTypeEnum.CUSTOMER_DEAL.getCode(),"enum.pageTitle.name.customer_deal",""),
    CUSTOMER_FOLLOW(XbbRefTypeEnum.CUSTOMER_FOLLOW.getCode(),"enum.pageTitle.name.customer_follow",""),
    CUSTOMER_RECYCLE(XbbRefTypeEnum.CUSTOMER_RECYCLE.getCode(),"enum.pageTitle.name.customer_recycle",""),
    CUSTOMER_PUBLIC(XbbRefTypeEnum.CUSTOMER_PUBLIC.getCode(),"enum.pageTitle.name.customer_public",""),
    CUSTOMER_NEARBY(XbbRefTypeEnum.CUSTOMER_NEARBY.getCode(),"enum.pageTitle.name.customer_nearby",""),
    CONTACT(XbbRefTypeEnum.CONTACT.getCode(),"enum.pageTitle.name.contact",""),
    CUSTOMER_COMMUNICATE(XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode(),"enum.pageTitle.name.customer_communicate",""),
    SUPPLIER_COMMUNICATE(XbbRefTypeEnum.SUPPLIER_COMMUNICATE.getCode(),"enum.pageTitle.name.supplier_communicate",""),
    COMMUNICATE_PLAN(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(),"enum.pageTitle.name.communicate_plan",""),
    CONTRACT(XbbRefTypeEnum.CONTRACT.getCode(),"enum.pageTitle.name.contract",""),
    SALES_OPPORTUNITY(XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(),"enum.pageTitle.name.sales_opportunity",""),
    ALL_OPPORTUNITY(XbbRefTypeEnum.ALL_OPPORTUNITY.getCode(),"enum.pageTitle.name.all_opportunity",""),
    KEY_OPPORTUNITY(XbbRefTypeEnum.KEY_OPPORTUNITY.getCode(),"enum.pageTitle.name.key_opportunity",""),
    WORK_REPORT(XbbRefTypeEnum.WORK_REPORT.getCode(),"enum.pageTitle.name.work_report",""),
    SIGNIN(XbbRefTypeEnum.SIGNIN.getCode(),"enum.pageTitle.name.signin",""),
    INVOICE(XbbRefTypeEnum.INVOICE.getCode(),"enum.pageTitle.name.invoice",""),
    PAYMENT(XbbRefTypeEnum.PAYMENT.getCode(),"enum.pageTitle.name.payment",""),
    PAY_PLAN(XbbRefTypeEnum.PAY_PLAN.getCode(),"enum.pageTitle.name.pay_plan",""),
    BOM_BILL(XbbRefTypeEnum.BOM_BILL.getCode(),"enum.pageTitle.name.bom_bill",""),
    PRODUCTION_ORDER(XbbRefTypeEnum.PRODUCTION_ORDER.getCode(),"enum.pageTitle.name.production_order",""),
    SUPPLIER(XbbRefTypeEnum.SUPPLIER.getCode(),"enum.pageTitle.name.supplier",""),
    SUPPLIER_CONTACT(XbbRefTypeEnum.SUPPLIER_CONTACT.getCode(),"enum.pageTitle.name.supplier_contact",""),
    PURCHASE(XbbRefTypeEnum.PURCHASE.getCode(),"enum.pageTitle.name.purchase",""),
    RETURNED_PURCHASE(XbbRefTypeEnum.RETURNED_PURCHASE.getCode(),"enum.pageTitle.name.returned_purchase",""),
    ASSEMBLE(XbbRefTypeEnum.ASSEMBLE.getCode(),"enum.pageTitle.name.assemble",""),
    INSTOCK(XbbRefTypeEnum.INSTOCK.getCode(),"enum.pageTitle.name.instock",""),
    OUTSTOCK(XbbRefTypeEnum.OUTSTOCK.getCode(),"enum.pageTitle.name.outstock",""),
    TRANSFER(XbbRefTypeEnum.TRANSFER.getCode(),"enum.pageTitle.name.transfer",""),
    INVENTORY(XbbRefTypeEnum.INVENTORY.getCode(),"enum.pageTitle.name.inventory",""),
    WAREHOUSE(XbbRefTypeEnum.WAREHOUSE.getCode(),"enum.pageTitle.name.warehouse",""),
    WORK_ORDER(XbbRefTypeEnum.WORK_ORDER.getCode(),"enum.pageTitle.name.work_order",""),
    WAIT_OUTSTOCK(XbbRefTypeEnum.WAIT_OUTSTOCK.getCode(),"enum.pageTitle.name.wait_outstock",""),
    WAIT_INSTOCK_PURCHASE(XbbRefTypeEnum.WAIT_INSTOCK_PURCHASE.getCode(),"enum.pageTitle.name.wait_instock_purchase",""),
    WAIT_PURCHASE(XbbRefTypeEnum.WAIT_PURCHASE.getCode(),"enum.pageTitle.name.wait_purchase",""),
    WAIT_PRODUCE(XbbRefTypeEnum.WAIT_PRODUCE.getCode(),"enum.pageTitle.name.wait_produce",""),
    PRODUCT(XbbRefTypeEnum.PRODUCT.getCode(),"enum.pageTitle.name.product",""),
    STOCK_SEARCH(XbbRefTypeEnum.STOCK_SEARCH.getCode(),"enum.pageTitle.name.stock_search",""),
    WARNING_SEARCH(XbbRefTypeEnum.WARNING_SEARCH.getCode(),"enum.pageTitle.name.warning_search",""),
    GUARANTEE_SEARCH(XbbRefTypeEnum.GUARANTEE_SEARCH.getCode(),"enum.pageTitle.name.guarantee_search",""),
    REFUND(XbbRefTypeEnum.REFUND.getCode(),"enum.pageTitle.name.refund",""),
    WORKORDER(XbbRefTypeEnum.WORK_ORDER.getCode(),"enum.pageTitle.name.workorder",""),
    WORKORDER_ROB(XbbRefTypeEnum.WORK_ORDER_ROB.getCode(),"enum.pageTitle.name.workorder_rob",""),
    QUOTATION(XbbRefTypeEnum.QUOTATION.getCode(), "enum.pageTitle.name.quotation", ""),

    ALL_CLUE(XbbRefTypeEnum.ALL_CLUE.getCode(),"enum.pageTitle.name.all_clue",""),
    CLUE_PUBLIC(XbbRefTypeEnum.CUSTOMER_RECYCLE.getCode(),"enum.pageTitle.name.clue_public",""),
    CLUE_RECYCLE(XbbRefTypeEnum.CLUE_RECYCLE.getCode(),"enum.pageTitle.name.clue_recycle",""),
    DISTRIBUTOR_MANAGEMENT(XbbRefTypeEnum.DISTRIBUTOR_MANAGEMENT.getCode(), "enum.xbbRefType.name.distributor_management", ""),
    DISTRIBUTOR_CONTACT(XbbRefTypeEnum.DISTRIBUTOR_CONTACT.getCode(), "enum.xbbRefType.name.distributor_contact", ""),
    DISTRIBUTOR_COMMUNICATE(XbbRefTypeEnum.DISTRIBUTOR_COMMUNICATE.getCode(), "enum.xbbRefType.name.distributor_communicate", ""),
    DISTRIBUTOR_ACCOUNT(XbbRefTypeEnum.DISTRIBUTOR_ACCOUNT.getCode(), "enum.xbbRefType.name.distributor_account", ""),
    ORDER(XbbRefTypeEnum.ORDER.getCode(), "enum.xbbRefType.name.order", ""),
    WRITE_OFF_RECORD(XbbRefTypeEnum.WRITE_OFF_RECORD.getCode(), "enum.xbbRefType.name.write_off_record", ""),
    WORK_ORDER_V2(XbbRefTypeEnum.WORK_ORDER_V2.getCode(), "enum.xbbRefType.name.work_order_v2", ""),
    SERVICE_PROJECT(XbbRefTypeEnum.SERVICE_PROJECT.getCode(), "enum.xbbRefType.name.service_project", ""),
    RETURN(XbbRefTypeEnum.RETURN.getCode(), "enum.xbbRefType.name.return", ""),
    ;
    private Integer code;
    private String name;
    private String alias;

    PageTitleEnum(Integer code, String name, String alias) {
        this.code = code;
        this.name = name;
        this.alias = alias;
    }

    public static PageTitleEnum getByCode(Integer code) {
        for (PageTitleEnum cacheCode : values()) {
            if (code.equals(cacheCode.getCode())) {
                return cacheCode;
            }
        }
        return null;
    }

    public String getName() {
        if (Objects.equals(name, "")) {
            return name;
        } else {
            return I18nMessageUtil.getMessage(name);
        }
    }
}
